<?php
class TourGiftVo extends SzAbstractMySqlVo
{

    private $userId;
    private $id;
    private $buySituation;
    private $rewardSituation;
    private $creatTime;
    private $updateTime;

    /**
     * Initialize TourGiftVo.
     *
     * @param $userId
     * @param $id
     * @param $buySituation
     * @param $rewardSituation
     * @param $creatTime
     * @param $updateTime
     * @param boolean $isInsert default false, means for now this vo is initialized not for insert process
     * @return TourGiftVo
     */
    public function __construct($userId, $id, $buySituation, $rewardSituation, $creatTime, $updateTime, $isInsert = false) {
        $this->userId = $userId;
        $this->id = $id;
        $this->buySituation = json_decode($buySituation, true);
        $this->rewardSituation = json_decode($rewardSituation, true);
        $this->creatTime = $creatTime;
        $this->updateTime = $updateTime;

        $this->isInsert = $isInsert;
        $this->voClassName = 'TourGiftVo';
        $this->ormName = 'TourGift';
    }

    /**
     * @see SzAbstractVo::toArray
     */
    public function toArray($needEncode = false)
    {
        return array(
            'userId' => $this->getUserId(),
            'id' => $this->getId(),
            'buySituation' => ($needEncode) ? $this->getBuySituation() : $this->getRawBuySituation(),
            'rewardSituation' => ($needEncode) ? $this->getRewardSituation() : $this->getRawRewardSituation(),
            'creatTime' => $this->getCreatTime(),
            'updateTime' => $this->getUpdateTime(),
        );
    }

    /**
     * @see SzAbstractVo::toEntireArray
     */
    public function toEntireArray($needEncode = false)
    {
        return array(
            'userId' => $this->getUserId(),
            'id' => $this->getId(),
            'buySituation' => ($needEncode) ? $this->getBuySituation() : $this->getRawBuySituation(),
            'rewardSituation' => ($needEncode) ? $this->getRewardSituation() : $this->getRawRewardSituation(),
            'creatTime' => $this->getCreatTime(),
            'updateTime' => $this->getUpdateTime(),
        );
    }

    /**
     * @see SzAbstractVo::toPureArray
     */
    public function toPureArray()
    {
        return array(
            $this->getUserId(),
            $this->getId(),
            $this->getBuySituation(),
            $this->getRewardSituation(),
            $this->getCreatTime(),
            $this->getUpdateTime(),
        );
    }

    public function getUserId()
    {
        return $this->userId;
    }

    public function setUserId($val)
    {
        $this->saveColumnStatus(0, $this->userId);
        $this->userId = $val;
    }

    public function getId()
    {
        return $this->id;
    }

    public function setId($val)
    {
        $this->saveColumnStatus(1, $this->id);
        $this->id = $val;
    }

    public function getBuySituation()
    {
        return json_encode($this->buySituation);
    }

    public function getRawBuySituation()
    {
        return $this->buySituation;
    }

    public function setBuySituation($val)
    {
        $encodedLength = SzUtility::strLen(json_encode($val));
        if ($encodedLength > 25600) {
            SzLogger::get()->error('[TourGiftVo] The length of column buySituation exceed the limit, length / limit: ' . $encodedLength . ' / 25600');
            throw new SzException(10522, array('TourGiftVo', '25600', $encodedLength));
        } else if ($encodedLength > 23040) {
            SzLogger::get()->warn('[TourGiftVo] The length of column buySituation exceed the warning level, length / limit: ' . $encodedLength . ' / 25600');
        }
        $this->saveColumnStatus(2, $this->buySituation);
        $this->buySituation = $val;
    }

    public function getRewardSituation()
    {
        return json_encode($this->rewardSituation);
    }

    public function getRawRewardSituation()
    {
        return $this->rewardSituation;
    }

    public function setRewardSituation($val)
    {
        $encodedLength = SzUtility::strLen(json_encode($val));
        if ($encodedLength > 25600) {
            SzLogger::get()->error('[TourGiftVo] The length of column rewardSituation exceed the limit, length / limit: ' . $encodedLength . ' / 25600');
            throw new SzException(10522, array('TourGiftVo', '25600', $encodedLength));
        } else if ($encodedLength > 23040) {
            SzLogger::get()->warn('[TourGiftVo] The length of column rewardSituation exceed the warning level, length / limit: ' . $encodedLength . ' / 25600');
        }
        $this->saveColumnStatus(3, $this->rewardSituation);
        $this->rewardSituation = $val;
    }

    public function getCreatTime()
    {
        return $this->creatTime;
    }

    public function setCreatTime($val)
    {
        $this->saveColumnStatus(4, $this->creatTime);
        $this->creatTime = $val;
    }

    public function getUpdateTime()
    {
        return $this->updateTime;
    }

    public function setUpdateTime($val)
    {
        $this->saveColumnStatus(5, $this->updateTime);
        $this->updateTime = $val;
    }

}